// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_prov;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.*;
import com.nnee.p_pr.p_prot.cls_c;
import java.util.*;

public class cls_ac extends  SQLiteOpenHelper
{

    public cls_ac(Context context)
    {
        this(context, "pris.db", null, 10);
    }

    private cls_ac(Context context, String s1, android.database.sqlite.SQLiteDatabase.CursorFactory cursorfactory, int i1)
    {
        super(context, s1, cursorfactory, i1);
    }

    private void A(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL("ALTER TABLE account ADD refresh INTEGER DEFAULT 0");
    }

    private void B(SQLiteDatabase sqlitedatabase)
    {
        String as[] = new String[9];
        as[0] = "account";
        as[1] = "name";
        as[2] = "last_login";
        as[3] = "type_weibo";
        as[4] = "other";
        as[5] = "token_weibo";
        as[6] = "secret_weibo";
        as[7] = "main_url";
        as[8] = "portrait_url";
        Cursor cursor = sqlitedatabase.query("weibo_account", as, null, null, null, null, null);
        if(cursor != null)
        {
            HashMap hashmap = new HashMap();
            if(cursor.moveToFirst())
                do
                {
                    ContentValues contentvalues2 = new ContentValues();
                    a(contentvalues2, cursor, "account", 0);
                    a(contentvalues2, cursor, "name", 1);
                    contentvalues2.put("last_login", Long.valueOf(cursor.getLong(2)));
                    int i1 = cursor.getInt(3);
                    contentvalues2.put("type_weibo", Integer.valueOf(i1));
                    a(contentvalues2, cursor, "other", 4);
                    a(contentvalues2, cursor, "token_weibo", 5);
                    a(contentvalues2, cursor, "secret_weibo", 6);
                    a(contentvalues2, cursor, "main_url", 7);
                    a(contentvalues2, cursor, "portrait_url", 8);
                    LinkedList linkedlist2 = (LinkedList)hashmap.get(Integer.valueOf(i1));
                    if(linkedlist2 == null)
                    {
                        linkedlist2 = new LinkedList();
                        hashmap.put(Integer.valueOf(i1), linkedlist2);
                    }
                    linkedlist2.add(contentvalues2);
                } while(cursor.moveToNext());
            cursor.close();
            if(hashmap.size() > 0)
            {
                String as1[] = new String[1];
                as1[0] = "name";
                Cursor cursor1 = sqlitedatabase.query("account", as1, null, null, null, null, null);
                if(cursor1 != null)
                {
                    LinkedList linkedlist = new LinkedList();
                    if(cursor1.moveToFirst())
                    {
                        do
                        {
                            String s2 = cursor1.getString(0);
                            if(s2 != null)
                                linkedlist.add(s2);
                        } while(cursor1.moveToNext());
                        cursor1.close();
                    }
                    if(!linkedlist.contains(c.b))
                        linkedlist.add(c.b);
                    for(Iterator iterator = hashmap.values().iterator(); iterator.hasNext();)
                    {
                        LinkedList linkedlist1 = (LinkedList)iterator.next();
                        ContentValues contentvalues = (ContentValues)linkedlist1.getFirst();
                        Iterator iterator1 = linkedlist.iterator();
                        while(iterator1.hasNext()) 
                        {
                            String s1 = (String)iterator1.next();
                            if(!a(linkedlist1, s1))
                            {
                                ContentValues contentvalues1 = new ContentValues(contentvalues);
                                contentvalues1.put("account", s1);
                                sqlitedatabase.insert("weibo_account", null, contentvalues1);
                            }
                        }
                    }

                }
            }
        }
    }

    public static ac a(Context context)
    {
        if(b == null)
            b = new cls_ac(context);
        return b;
    }

    private void a(ContentValues contentvalues, Cursor cursor, String s1, int i1)
    {
        String s2 = cursor.getString(i1);
        if(s2 != null)
            contentvalues.put(s1, s2);
    }

    private boolean a(LinkedList linkedlist, String s1)
    {
        Iterator iterator = linkedlist.iterator();
_L4:
        if(!iterator.hasNext()) goto _L2; else goto _L1
_L1:
        if(!s1.equals(((ContentValues)iterator.next()).getAsString("account"))) goto _L4; else goto _L3
_L3:
        boolean flag = true;
_L6:
        return flag;
_L2:
        flag = false;
        if(true) goto _L6; else goto _L5
_L5:
    }

    private void q(SQLiteDatabase sqlitedatabase)
    {
        B(sqlitedatabase);
    }

    private void r(SQLiteDatabase sqlitedatabase)
    {
        A(sqlitedatabase);
        sqlitedatabase.execSQL(" drop table if exists fonts");
        f(sqlitedatabase);
    }

    private void s(SQLiteDatabase sqlitedatabase)
    {
        z(sqlitedatabase);
    }

    private void t(SQLiteDatabase sqlitedatabase)
    {
        y(sqlitedatabase);
    }

    private void u(SQLiteDatabase sqlitedatabase)
    {
        x(sqlitedatabase);
    }

    private void v(SQLiteDatabase sqlitedatabase)
    {
        w(sqlitedatabase);
        onCreate(sqlitedatabase);
    }

    private void w(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("account").toString());
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("weibo_account").toString());
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("subscribe").toString());
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("cachetabable").toString());
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("favorite").toString());
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("config").toString());
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("search").toString());
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("conver").toString());
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("article_status").toString());
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("offline").toString());
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("fonts").toString());
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("temp_subcribe").toString());
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("temp_article").toString());
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("temp_comment").toString());
        sqlitedatabase.execSQL((new StringBuilder()).append(" drop table if exists  ").append("temp_search").toString());
_L1:
        return;
        SQLiteException sqliteexception;
        sqliteexception;
        sqliteexception.printStackTrace();
          goto _L1
    }

    private void x(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" UPDATE subscribe SET seq = _id");
    }

    private void y(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL("ALTER TABLE subscribe ADD refresh INTEGER DEFAULT 0");
    }

    private void z(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" ALTER TABLE offline RENAME TO offline_tmp; ");
        sqlitedatabase.execSQL(" CREATE TABLE offline ( _id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL, uid TEXT NOT NULL, other TEXT, UNIQUE (uid, account) ON CONFLICT REPLACE );");
        sqlitedatabase.execSQL(" INSERT INTO offline SELECT _id, account, uid, other FROM offline_tmp; ");
        sqlitedatabase.execSQL(" DROP TABLE offline_tmp; ");
    }

    void a(SQLiteDatabase sqlitedatabase)
    {
        b(sqlitedatabase);
        c(sqlitedatabase);
        d(sqlitedatabase);
        g(sqlitedatabase);
        h(sqlitedatabase);
        i(sqlitedatabase);
        j(sqlitedatabase);
        k(sqlitedatabase);
        l(sqlitedatabase);
        e(sqlitedatabase);
        f(sqlitedatabase);
        m(sqlitedatabase);
        n(sqlitedatabase);
        o(sqlitedatabase);
        p(sqlitedatabase);
    }

    void b(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" CREATE TABLE account ( _id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, password TEXT NOT NULL,last_login INTEGER, auot_login BOOL default true,main INTEGER default 0,other TEXT,first_login INTEGER default 0,refresh INTEGER default 0, UNIQUE (name) ON CONFLICT REPLACE ) ");
    }

    void c(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" CREATE TABLE weibo_account ( _id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL, name TEXT NOT NULL, last_login INTEGER, type_weibo INTEGER, token_weibo TEXT, secret_weibo TEXT, main_url TEXT, portrait_url TEXT, other TEXT, UNIQUE (name , account , type_weibo) ON CONFLICT REPLACE ) ");
    }

    void d(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" CREATE TABLE subscribe ( _id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL, uid TEXT NOT NULL,updated TEXT,title TEXT,type INTEGER DEFAULT 1 ,content TEXT , seq INTEGER , other TEXT ,refresh INTEGER DEFAULT 0 , UNIQUE (uid,account) ON CONFLICT REPLACE ) ");
    }

    void e(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" CREATE TABLE offline ( _id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL, uid TEXT NOT NULL,other TEXT, UNIQUE (uid, account) ON CONFLICT REPLACE ) ");
    }

    void f(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" CREATE TABLE fonts ( _id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, url TEXT NOT NULL,desc TEXT,len INTEGER default 0,md TEXT,path TEXT,state INTEGER default 0, UNIQUE (name) ON CONFLICT IGNORE ) ");
    }

    void g(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" CREATE TABLE favorite ( _id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL, uid TEXT NOT NULL,updated TEXT,title TEXT,timestamp INTEGER,other TEXT,file TEXT,type TEXT, UNIQUE (uid,account) ON CONFLICT REPLACE ) ");
    }

    void h(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL("CREATE TABLE cachetabable (_id INTEGER PRIMARY KEY, account TEXT, url TEXT, filepath TEXT, lastmodify TEXT, etag TEXT, expires INTEGER, expiresstring TEXT, encoding TEXT,contentlength INTEGER, timestamp INTEGER,data1 TEXT, UNIQUE (url) ON CONFLICT REPLACE);");
    }

    void i(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL("CREATE TABLE config(_id INTEGER PRIMARY KEY AUTOINCREMENT,group_name TEXT not null,name TEXT not null,value TEXT,type INTEGER default 2 ,UNIQUE (name,group_name ) ON CONFLICT REPLACE)");
    }

    void j(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" CREATE TABLE search(_id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL,content TEXT NOT NULL,timestamp INTEGER,other TEXT,UNIQUE ( account,content ) ON CONFLICT REPLACE)");
    }

    void k(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" CREATE TABLE article_status ( _id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT, uid TEXT NOT NULL,status INTEGER,timestamp INTEGER,other TEXT,UNIQUE ( account,uid ) ON CONFLICT REPLACE ) ");
        sqlitedatabase.execSQL(" CREATE TRIGGER max_size_trigger  AFTER INSERT  ON article_status WHEN (SELECT COUNT(*) FROM article_status )  > 1000 BEGIN  DELETE FROM article_status WHERE timestamp <=  0.1 * (SELECT MAX(timestamp)  FROM article_status)  + 0.9 * (SELECT MIN(timestamp)  FROM article_status) ; END; ");
    }

    void l(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" create table conver(_id INTEGER PRIMARY KEY AUTOINCREMENT, uid TEXT not null,updated TEXT,type TEXT ,flag INTEGER default 0,image TEXT ,path TEXT ,thumn_image TEXT ,thumb_path TEXT ,other TEXT )");
    }

    void m(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" CREATE TABLE temp_subcribe(_id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL,title TEXT,uid TEXT NOT NULL,updated TEXT, subcribable INTEGER default 0,subcribed INTEGER default 0,rank INTEGER default 0,type INTEGER ,content TEXT ,other TEXT ,UNIQUE ( account,uid ) ON CONFLICT REPLACE)");
    }

    void n(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" CREATE TABLE temp_comment(_id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL,title TEXT,uid TEXT NOT NULL,updated TEXT ,user TEXT ,content TEXT, article_uid TEXT ,other TEXT ,UNIQUE ( account,uid,article_uid ) ON CONFLICT REPLACE)");
    }

    void o(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" CREATE TABLE temp_article(_id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL,title TEXT,uid TEXT NOT NULL,updated TEXT ,favorite INTEGER default 0,file TEXT , stream TEXT,content TEXT, other TEXT, UNIQUE ( account,uid ) ON CONFLICT REPLACE)");
    }

    public void onCreate(SQLiteDatabase sqlitedatabase)
    {
        a(sqlitedatabase);
    }

    public void onUpgrade(SQLiteDatabase sqlitedatabase, int i1, int j1)
    {
        if(i1 != j1) goto _L2; else goto _L1
_L1:
        return;
_L2:
        if(i1 > j1)
        {
            v(sqlitedatabase);
            continue; /* Loop/switch isn't completed */
        }
        if(i1 >= 5)
            break; /* Loop/switch isn't completed */
        v(sqlitedatabase);
        if(true) goto _L1; else goto _L3
_L3:
        switch(i1)
        {
        case 5: // '\005'
            u(sqlitedatabase);
            // fall through

        case 6: // '\006'
            t(sqlitedatabase);
            // fall through

        case 7: // '\007'
            s(sqlitedatabase);
            // fall through

        case 8: // '\b'
            r(sqlitedatabase);
            // fall through

        case 9: // '\t'
            q(sqlitedatabase);
            break;
        }
        if(true) goto _L1; else goto _L4
_L4:
    }

    void p(SQLiteDatabase sqlitedatabase)
    {
        sqlitedatabase.execSQL(" CREATE TABLE temp_search(_id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT NOT NULL,title TEXT,uid TEXT NOT NULL,updated TEXT ,subcribable INTEGER default 0,subcribed INTEGER default 0,rank INTEGER default 0,content TEXT ,other TEXT ,UNIQUE ( account,uid ) ON CONFLICT REPLACE)");
    }

    static final String a = "SQLiteOpenHelperEx";
    private static ac b = null;

}
